<?php
namespace App\Listeners;

use App\Events\AdminLogged;
use App\Models\Userlog;
use Illuminate\Contracts\Queue\ShouldQueue;

class RecordAdminLoginLog implements ShouldQueue
{
    /**
     * Create the event listener.
     * @return void
     */
    public function __construct()
    {
    }

    /**
     * Handle the event.
     * @param  AdminLogged  $event
     * @return void
     */
    public function handle(AdminLogged $event)
    {
        $log = new Userlog;
        $log->user_id = $event->user_id;
        $log->login_ip = $event->login_ip;
        $log->login_at = time();
        return $log->save();
    }
}
